import { CheckableTagGroup } from '@/components/antds/CheckableTagGroup';
import { UploadFile } from 'antd';
import { UploaderHistoryRender } from './UploaderStyle';

export interface IHistoryFiles<T = string> {
  label: string;
  value: T;
  /** 此处显示创建时间 */ subtitle?: string;
  uid?: string;
}

interface Props {
  selectedList?: UploadFile[];
  dataList: IHistoryFiles[];
  onChange: (value: string, options?: string[], selectedItem?: any) => void;
  disabled?: boolean;
}

export const UploaderHistory: React.FC<Props> = (props) => {
  const { selectedList = [], dataList = [], onChange, disabled } = props;

  return (
    <UploaderHistoryRender className="uploader-history">
      <div className="uploader-history-title">选择历史文件</div>
      <div className="uploader-history-content">
        <CheckableTagGroup
          disabled={disabled}
          selectedList={selectedList.map((item) => item?.name)}
          dataList={[...dataList]}
          onChange={onChange}
        />
      </div>
    </UploaderHistoryRender>
  );
};
